package cn.yh.register.task;

import cn.yh.register.common.constant.MqConst;
import cn.yh.register.common.service.RabbitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Slf4j
@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    RabbitService rabbitService;

    //每天早上八点执行
    // @Scheduled(cron = "0/2 * * * * ?")//每隔5秒一次
    @Scheduled(cron = "0 0 8 * * ? ")//每隔5秒一次
    public void task(){
        System.out.println("定时任务执行了");
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK, MqConst.ROUTING_TASK_8, "");
        log.info("发送消息...");
    }
}
